package com.bins.langchain.easy.rag.config;

import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.model.ollama.OllamaChatModel;
import dev.langchain4j.rag.content.retriever.EmbeddingStoreContentRetriever;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

@Configuration
public class AppConfig {

    @Bean
    public OllamaChatModel createModel() {
        OllamaChatModel chatModel = OllamaChatModel.builder()
                .baseUrl("http://127.0.0.1:11434")
                .modelName("qwen2")
                .temperature(0d)
                .timeout(Duration.ofSeconds(3000))
                .maxRetries(3)
                .logRequests(true)
                .logResponses(true)
                .build();
        return chatModel;
    }

    @Bean
    public EmbeddingStore<TextSegment> createEmbeddingStore() {
        return new InMemoryEmbeddingStore<TextSegment>();
    }
}

